#pragma once

#include <iostream>
#include <string>
#include <unistd.h>
#include <fcntl.h>

#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0)

#define CONV(v) (struct sockaddr *)(v)

enum
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR,
    LISTEN_ERR,
    EPOLL_CREATE_ERR,
    EPOLL_CTL_ERR
};

const int gdefaultsockfd = -1;
const int gbacklog = 8;

void SetNonBloack(int sockfd)
{
    int f1 = fcntl(sockfd, F_GETFL);
    if(f1 < 0)
    {
        return;
    }
    fcntl(sockfd, F_SETFL, f1 | O_NONBLOCK);
}

